<template>
	<div class="form-box">
		<h2 class="title">注册XMall账号</h2>
		<form>
			<div class="form-group">用户名:
				<input class="kk" type="text" placeholder="用户名" v-model="user.userName">
			</div>
			<div class="form-group">密码:
				<input class="kk" type="password" placeholder="密码" v-model="user.password">
			</div>
			<div class="form-group">确认密码:
				<input class="kk" type="password" placeholder="确认密码">
			</div>
			<div class="form-group">
				<label style="display: flex; align-items: center;">
					<input type="checkbox">
					我已阅读并同意遵守&nbsp;
					<a href="#">法律声明</a>
					&nbsp;和&nbsp;
					<a href="#">隐私条款</a>
				</label>
			</div>
			<div class="form-group">
				<button id="btnReg" class="kk" type="button" @click="register">注册</button>
			</div>
		</form>
		<div style="text-align: center;">
			已有账号，去&nbsp;<router-link to="Login">登录</router-link>
		</div>
	</div>
</template>
<script>
	export default {
		data() {
			return {
				user: {
					userName: '',
					password: ''
				},
				truepassword: ''
			}
		},
		methods: {
			register() {
				if (this.user.password==this.truepassword) {
					this.axios.post('/register', this.user)
						.then(response => {
							let res = response.data;
							this.$message(res.msg);
						})
				}else
				this.$message('两次密码不一致')
			}
		},
	}
</script>

<style scoped="scoped">
	html,
	body {
		height: 100%;
	}

	body {
		background-image: url(../assets/img/register-body-bg.png);
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.form-box {
		width: 450px;
		/* height: 550px; */
		border-radius: 8px;
		background-image: linear-gradient(to bottom, white, #EFEFF0);
		box-shadow: 15px 15px 15px 0px #CCCCCC;
		padding: 40px;
		margin: 0 auto;
	}

	.title {
		border-bottom: 1px solid #CCCCCC;
		padding-bottom: 15px;
		margin: 0px -40px 20px;
		text-align: center;
	}

	.form-group {
		margin-bottom: 20px;
	}

	.kk {
		padding: 10px;
		width: 100%;
	}

	form {
		padding-bottom: 20px;
		margin-bottom: 20px;
		border-bottom: 1px solid #CCCCCC;
	}

	a {
		color: blue;
	}
</style>
